home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performAimConstraint.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  18.6 KB  |  701 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  24 April 1997
  22. //
  23. //  Description:
  24. //        This script provides an option box dialog for the aimConstraint command.
  25. //
  26. //    Input Arguments:
  27. //        boolean showOptionBox    true - show the option box dialog
  28. //                                false - just execute the command
  29. //
  30.  
  31. //
  32. //  Procedure Name:
  33. //      setOptionVars
  34. //
  35. //  Description:
  36. //        Initialize the option values.
  37. //
  38. //  Input Arguments:
  39. //        Whether to set the options to default values.
  40. //
  41. //  Return Value:
  42. //      None.
  43. //
  44. proc setOptionVars(int $forceFactorySettings)
  45. {
  46.     //    weight
  47.     //
  48.     if ($forceFactorySettings || !`optionVar -exists aimConstraintWeight`) {
  49.         optionVar -floatValue aimConstraintWeight 1.0;
  50.     }
  51.  
  52.     //    aimVector.
  53.     //
  54.     if ($forceFactorySettings || !`optionVar -exists aimConstraintAimVector`) {
  55.         optionVar -floatValue aimConstraintAimVector 1.0
  56.             -floatValueAppend aimConstraintAimVector 0.0
  57.             -floatValueAppend aimConstraintAimVector 0.0;
  58.     }
  59.  
  60.     //    upVector.
  61.     //
  62.     if ($forceFactorySettings || !`optionVar -exists aimConstraintUpVector`) {
  63.         optionVar -floatValue aimConstraintUpVector 0.0
  64.             -floatValueAppend aimConstraintUpVector 1.0
  65.             -floatValueAppend aimConstraintUpVector 0.0;
  66.     }
  67.  
  68.     // World up
  69.  
  70.     if ($forceFactorySettings || !`optionVar -exists aimConstraintWorldUpType`) {
  71.         optionVar -stringValue aimConstraintWorldUpType "vector";
  72.     }
  73.  
  74.     if ($forceFactorySettings || !`optionVar -exists aimConstraintWorldUpVector`) {
  75.         optionVar -floatValue aimConstraintWorldUpVector 0.0
  76.             -floatValueAppend aimConstraintWorldUpVector 1.0
  77.             -floatValueAppend aimConstraintWorldUpVector 0.0;
  78.     }
  79.  
  80.     if ($forceFactorySettings || !`optionVar -exists aimConstraintWorldUpObject`) {
  81.         optionVar -stringValue aimConstraintWorldUpObject "";
  82.     }
  83.  
  84.     // offset x,y,z
  85.     //
  86.     if ($forceFactorySettings || 
  87.         !`optionVar -exists aimConstOffsetX`) {
  88.         optionVar -floatValue aimConstOffsetX 0.0;
  89.     }
  90.     if ($forceFactorySettings || 
  91.         !`optionVar -exists aimConstOffsetY`) {
  92.         optionVar -floatValue aimConstOffsetY 0.0;
  93.     }
  94.     if ($forceFactorySettings || 
  95.         !`optionVar -exists aimConstOffsetZ`) {
  96.         optionVar -floatValue aimConstOffsetZ 0.0;
  97.     }
  98.  
  99.     // maintain existing offset
  100.     //
  101.     if ($forceFactorySettings || 
  102.         !`optionVar -exists aimConstMaintainOffset`) {
  103.         optionVar -intValue aimConstMaintainOffset 0;
  104.     }
  105.     
  106.     // Constraint Axes
  107.     //
  108.     if ($forceFactorySettings ||
  109.         !`optionVar -exists  aimConstraintAxisX`) {
  110.         optionVar -intValue aimConstraintAxisX true;
  111.     }
  112.     if ($forceFactorySettings ||
  113.         !`optionVar -exists  aimConstraintAxisY`) {
  114.         optionVar -intValue aimConstraintAxisY true;
  115.     }
  116.     if ($forceFactorySettings ||
  117.         !`optionVar -exists  aimConstraintAxisZ`) {
  118.         optionVar -intValue aimConstraintAxisZ true;
  119.     }
  120. }
  121.  
  122. //
  123. //  Procedure Name:
  124. //      aimConstraintSetup
  125. //
  126. //  Description:
  127. //        Update the state of the option box UI to reflect the option values.
  128. //
  129. //  Input Arguments:
  130. //      parent               - Top level parent layout of the option box UI.
  131. //                             Required so that UI object names can be 
  132. //                             successfully resolved.
  133. //
  134. //        forceFactorySettings - Whether the option values should be set to
  135. //                             default values.
  136. //
  137. //  Return Value:
  138. //      None.
  139. //
  140. global proc aimConstraintSetup(string $parent, int $forceFactorySettings)
  141. {
  142.     //    Retrieve the option settings
  143.     //
  144.     setOptionVars($forceFactorySettings);
  145.  
  146.     setParent $parent;
  147.  
  148.     //    Query the optionVar's and set the values into the controls.
  149.  
  150.     //    weight
  151.     //
  152.     floatSliderGrp -edit 
  153.         -value `optionVar -query aimConstraintWeight`
  154.         aimConstraintWeight;
  155.  
  156.     //    aimVector.
  157.     //
  158.     float $aimVector[] = `optionVar -query aimConstraintAimVector`;
  159.     floatFieldGrp -edit 
  160.         -value1 $aimVector[0]
  161.         -value2 $aimVector[1]
  162.         -value3 $aimVector[2]
  163.         aimConstraintAimVector;
  164.  
  165.     //    upVector.
  166.     //
  167.     float $upVector[] = `optionVar -query aimConstraintUpVector`;
  168.     floatFieldGrp -edit 
  169.         -value1 $upVector[0]
  170.         -value2 $upVector[1]
  171.         -value3 $upVector[2]
  172.         aimConstraintUpVector;
  173.  
  174.     // World up
  175.  
  176.     string $worldUpType = `optionVar -query aimConstraintWorldUpType`;
  177.     switch ( $worldUpType )
  178.     {
  179.     case "scene":
  180.         optionMenuGrp -edit -select 1 aimConstraintWorldUpType;
  181.         break;
  182.     case "object":
  183.         optionMenuGrp -edit -select 2 aimConstraintWorldUpType;
  184.         break;
  185.     case "objectrotation":
  186.         optionMenuGrp -edit -select 3 aimConstraintWorldUpType;
  187.         break;
  188.     case "vector":
  189.         optionMenuGrp -edit -select 4 aimConstraintWorldUpType;
  190.         break;
  191.     case "none":
  192.         optionMenuGrp -edit -select 5 aimConstraintWorldUpType;
  193.         break;
  194.     }
  195.  
  196.     float $worldUpVector[] = `optionVar -query aimConstraintWorldUpVector`;
  197.     floatFieldGrp -edit 
  198.         -value1 $worldUpVector[0]
  199.         -value2 $worldUpVector[1]
  200.         -value3 $worldUpVector[2]
  201.         aimConstraintWorldUpVector;
  202.  
  203.     textFieldGrp -edit
  204.         -text `optionVar -query aimConstraintWorldUpObject`
  205.         aimConstraintWorldUpObject;
  206.  
  207.     //    Offset values
  208.     //
  209.     float $rx = `optionVar -query aimConstOffsetX`;
  210.     float $ry = `optionVar -query aimConstOffsetY`;
  211.     float $rz = `optionVar -query aimConstOffsetZ`;
  212.     if (`optionVar -query aimConstMaintainOffset`) {
  213.         checkBoxGrp -edit -value1 1 aimConstraintMaintainWidget;
  214.         floatFieldGrp -edit -enable 0 offsetField;
  215.     } else {
  216.         checkBoxGrp -edit -value1 0 aimConstraintMaintainWidget;
  217.         floatFieldGrp -edit -enable 1 offsetField;
  218.     }
  219.     floatFieldGrp -e -v1 $rx -v2 $ry -v3 $rz offsetField;
  220.     
  221.     //  Axis values
  222.     //
  223.     int $axisX = `optionVar -query aimConstraintAxisX`;
  224.     int $axisY = `optionVar -query aimConstraintAxisY`;
  225.     int $axisZ = `optionVar -query aimConstraintAxisZ`;
  226.     // if all axes are on, select the all box and dim the individual axes
  227.     if ($axisX && $axisY && $axisZ) {
  228.         checkBoxGrp -edit -value1 true axesAll;
  229.         checkBoxGrp -edit -value1 false -value2 false -value3 false axesXYZ;
  230.     }
  231.     // otherwise just select those boxes corresponding to 'on' axes
  232.     else {
  233.         checkBoxGrp -edit -value1 false axesAll;
  234.         checkBoxGrp -edit -value1 $axisX -value2 $axisY -value3 $axisZ axesXYZ;
  235.     }
  236.  
  237.     aimConstraintEnabling $parent;
  238. }
  239.  
  240. //
  241. //  Procedure Name:
  242. //      aimConstraintCallback
  243. //
  244. //  Description:
  245. //        Update the option values with the current state of the option box UI.
  246. //
  247. //  Input Arguments:
  248. //      parent - Top level parent layout of the option box UI.  Required so
  249. //               that UI object names can be successfully resolved.
  250. //
  251. //        doIt   - Whether the command should execute.
  252. //
  253. //  Return Value:
  254. //      None.
  255. //
  256. global proc aimConstraintCallback(string $parent, int $doIt)
  257. {
  258.     setParent $parent;
  259.  
  260.     //    Set the optionVar's from the control values, and then
  261.     //    perform the command.
  262.  
  263.     //    weight
  264.     //
  265.     optionVar -floatValue aimConstraintWeight
  266.         `floatSliderGrp -query -value aimConstraintWeight`;
  267.  
  268.     //    aimVector.
  269.     //
  270.     optionVar -floatValue aimConstraintAimVector
  271.         `floatFieldGrp -query -value1 aimConstraintAimVector`
  272.         -floatValueAppend aimConstraintAimVector
  273.         `floatFieldGrp -query -value2 aimConstraintAimVector`
  274.         -floatValueAppend aimConstraintAimVector
  275.         `floatFieldGrp -query -value3 aimConstraintAimVector`;
  276.  
  277.     //    upVector.
  278.     //
  279.     optionVar -floatValue aimConstraintUpVector
  280.         `floatFieldGrp -query -value1 aimConstraintUpVector`
  281.         -floatValueAppend aimConstraintUpVector
  282.         `floatFieldGrp -query -value2 aimConstraintUpVector`
  283.         -floatValueAppend aimConstraintUpVector
  284.         `floatFieldGrp -query -value3 aimConstraintUpVector`;
  285.  
  286.     // World up
  287.  
  288.     int $state = `optionMenuGrp -query -select aimConstraintWorldUpType`;
  289.     switch ( $state )
  290.     {
  291.     case 1:
  292.         optionVar -stringValue aimConstraintWorldUpType "scene";
  293.         break;
  294.     case 2:
  295.         optionVar -stringValue aimConstraintWorldUpType "object";
  296.         break;
  297.     case 3:
  298.         optionVar -stringValue aimConstraintWorldUpType "objectrotation";
  299.         break;
  300.     case 4:
  301.         optionVar -stringValue aimConstraintWorldUpType "vector";
  302.         break;
  303.     case 5:
  304.         optionVar -stringValue aimConstraintWorldUpType "none";
  305.         break;
  306.     }
  307.  
  308.     optionVar -floatValue aimConstraintWorldUpVector
  309.         `floatFieldGrp -query -value1 aimConstraintWorldUpVector`
  310.         -floatValueAppend aimConstraintWorldUpVector
  311.         `floatFieldGrp -query -value2 aimConstraintWorldUpVector`
  312.         -floatValueAppend aimConstraintWorldUpVector
  313.         `floatFieldGrp -query -value3 aimConstraintWorldUpVector`;
  314.  
  315.     optionVar -stringValue aimConstraintWorldUpObject
  316.         `textFieldGrp -query -text aimConstraintWorldUpObject`;
  317.  
  318.     // Maintain offset 
  319.     //
  320.     optionVar -intValue aimConstMaintainOffset `checkBoxGrp  -query -value1 aimConstraintMaintainWidget`;
  321.     
  322.     //    Offset values
  323.     //
  324.     optionVar -floatValue aimConstOffsetX
  325.         `floatFieldGrp -query -v1 offsetField`;
  326.     optionVar -floatValue aimConstOffsetY
  327.         `floatFieldGrp -query -v2 offsetField`;
  328.     optionVar -floatValue aimConstOffsetZ
  329.         `floatFieldGrp -query -v3 offsetField`;
  330.  
  331.     // Axis values
  332.     //
  333.  
  334.     // Either the 'All' box is checked (and so all axes are on) ...
  335.     if ( `checkBoxGrp -query -value1 axesAll` ) {
  336.         optionVar -intValue aimConstraintAxisX true;
  337.         optionVar -intValue aimConstraintAxisY true;
  338.         optionVar -intValue aimConstraintAxisZ true;
  339.     } else {
  340.         // ... Or only those axes specifically selected are on
  341.         optionVar -intValue aimConstraintAxisX
  342.             `checkBoxGrp -query -value1 axesXYZ`;
  343.         optionVar -intValue aimConstraintAxisY
  344.             `checkBoxGrp -query -value2 axesXYZ`;
  345.         optionVar -intValue aimConstraintAxisZ
  346.             `checkBoxGrp -query -value3 axesXYZ`;
  347.     }
  348.  
  349.     if ($doIt) {
  350.         performAimConstraint 0; 
  351.         addToRecentCommandQueue "performAimConstraint 0" "AimConstraint";
  352.     }
  353. }
  354.  
  355. // Callbacks to dim/undim different widget
  356. //
  357. global proc aimConstraintEnabling(string $parent)
  358. {
  359.     setParent $parent;
  360.  
  361.     int $state = `optionMenuGrp -query -select aimConstraintWorldUpType`;
  362.     switch ( $state )
  363.     {
  364.     case 1: // Scene Up
  365.     case 5: // None
  366.         floatFieldGrp -edit -enable false aimConstraintWorldUpVector;
  367.         textFieldGrp -edit -enable false aimConstraintWorldUpObject;
  368.         break;
  369.     case 2: // Object Up
  370.         floatFieldGrp -edit -enable false aimConstraintWorldUpVector;
  371.         textFieldGrp -edit -enable true aimConstraintWorldUpObject;
  372.         break;
  373.     case 3: // Object Rotation Up
  374.         floatFieldGrp -edit -enable true aimConstraintWorldUpVector;
  375.         textFieldGrp -edit -enable true aimConstraintWorldUpObject;
  376.         break;
  377.     case 4: // Vector
  378.         floatFieldGrp -edit -enable true aimConstraintWorldUpVector;
  379.         textFieldGrp -edit -enable false aimConstraintWorldUpObject;
  380.         break;
  381.     }
  382. }
  383.  
  384. //
  385. //  Procedure Name:
  386. //      aimConstraintOptions
  387. //
  388. //  Description:
  389. //        Construct the option box UI.  Involves accessing the standard option
  390. //        box and customizing the UI accordingly.
  391. //
  392. //  Input Arguments:
  393. //      None.
  394. //
  395. //  Return Value:
  396. //      None.
  397. //
  398. proc aimConstraintOptions()
  399. {
  400.     //    Name of the command for this option box.
  401.     //
  402.     string $commandName = "aimConstraint";
  403.  
  404.     //    Build the option box actions.
  405.     //
  406.     string $callback = ($commandName + "Callback");
  407.     string $setup = ($commandName + "Setup");
  408.  
  409.     //    Get the option box.
  410.     //
  411.     string $layout = getOptionBox();
  412.     setParent $layout;
  413.     
  414.     //    Pass the command name to the option box.
  415.     //
  416.     setOptionBoxCommandName($commandName);
  417.     
  418.     //    Activate the default UI template.
  419.     //
  420.     setUITemplate -pushTemplate DefaultTemplate;
  421.  
  422.     //    Turn on the wait cursor.
  423.     //
  424.     waitCursor -state 1;
  425.  
  426.     tabLayout -scr true -tv false;
  427.     string $parent = `columnLayout -adjustableColumn 1`;
  428.  
  429.     checkBoxGrp
  430.         -label "Maintain Offset"
  431.         -label1 " "
  432.         -annotation "Preserve the initial offset between the object and the target(s)"
  433.         -numberOfCheckBoxes 1
  434.         -cc ("floatFieldGrp -edit -enable (! #1) offsetField;")
  435.         aimConstraintMaintainWidget;
  436.     
  437.     floatFieldGrp -label "Offset"
  438.         -numberOfFields 3
  439.         offsetField;
  440.     
  441.     separator;
  442.  
  443.     floatFieldGrp -label "Aim Vector"
  444.         -numberOfFields 3
  445.         aimConstraintAimVector;
  446.  
  447.     floatFieldGrp -label "Up Vector"
  448.         -numberOfFields 3
  449.         aimConstraintUpVector;
  450.  
  451.     optionMenuGrp -l "World Up Type"
  452.         -cc ("aimConstraintEnabling " + $parent)
  453.         aimConstraintWorldUpType;
  454.         menuItem -l "Scene Up"           aimConstraintUpDirMI1;
  455.         menuItem -l "Object Up"          aimConstraintUpDirMI2;
  456.         menuItem -l "Object Rotation Up" aimConstraintUpDirMI3;
  457.         menuItem -l "Vector"             aimConstraintUpDirMI4;
  458.         menuItem -l "None"               aimConstraintUpDirMI5;
  459.  
  460.     floatFieldGrp -l "World Up Vector" -nf 3 aimConstraintWorldUpVector;
  461.  
  462.     textFieldGrp -l "World Up Object" aimConstraintWorldUpObject;
  463.  
  464.     separator;
  465.  
  466.     //  Constraint Axes Selection Boxes
  467.     //
  468.  
  469.     // The 'axesAll' checkBoxGrp and the 'axesXYZ' checkBoxGrp are linked
  470.     // such that when 'axesAll' is selected, all the 'axesXYZ' boxes are
  471.     // unselected. And when any 'axesXYZ' box is selected the 'axesAll'
  472.     // box is deselected.
  473.     checkBoxGrp -numberOfCheckBoxes 1 -label "Constraint Axes"
  474.         -label1 "All"
  475.         -onCommand ("checkBoxGrp -edit " +
  476.                     "-value1 false " +
  477.                     "-value2 false " +
  478.                     "-value3 false " +
  479.                     "axesXYZ")
  480.         axesAll;
  481.         
  482.     checkBoxGrp -numberOfCheckBoxes 3
  483.         -label1 "X"
  484.         -label2 "Y"
  485.         -label3 "Z"
  486.         -onCommand ("checkBoxGrp -edit " +
  487.                     "-value1 false " +
  488.                     "axesAll;")
  489.         axesXYZ;
  490.  
  491.     separator;
  492.     
  493.     floatSliderGrp -label "Weight"
  494.         -field true -min 0.0 -max 10.0 
  495.         aimConstraintWeight;
  496.  
  497.     //    Turn off the wait cursor.
  498.     //
  499.     waitCursor -state 0;
  500.     
  501.     //    Deactivate the default UI template.
  502.     //
  503.     setUITemplate -popTemplate;
  504.  
  505.     //    'Apply' button.
  506.     //
  507.     string $applyBtn = getOptionBoxApplyBtn();
  508.     button -edit
  509.         -label "Add"
  510.         -command ($callback + " " + $parent + " " + 1)
  511.         $applyBtn;
  512.  
  513.     //    'Save' button.
  514.     //
  515.     string $saveBtn = getOptionBoxSaveBtn();
  516.     button -edit 
  517.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  518.         $saveBtn;
  519.  
  520.     //    'Reset' button.
  521.     //
  522.     string $resetBtn = getOptionBoxResetBtn();
  523.     button -edit 
  524.         -command ($setup + " " + $parent + " " + 1)
  525.         $resetBtn;
  526.  
  527.     //    Set the option box title.
  528.     //
  529.     setOptionBoxTitle("Aim Constraint Options");
  530.  
  531.     //    Customize the 'Help' menu item text.
  532.     //
  533.     setOptionBoxHelpTag( "Aim" );
  534.  
  535.     //    Set the current values of the option box.
  536.     //
  537.     eval (($setup + " " + $parent + " " + 0));    
  538.     
  539.     //    Show the option box.
  540.     //
  541.     showOptionBox();
  542. }
  543.  
  544.  
  545. //
  546. //  Procedure Name:
  547. //      assembleCmd
  548. //
  549. //  Description:
  550. //        Construct the command that will apply the option box values.
  551. //
  552. //  Input Arguments:
  553. //      None.
  554. //
  555. //  Return Value:
  556. //      None.
  557. //
  558. proc string assembleCmd()
  559. {
  560.     string $cmd = "aimConstraint";
  561.  
  562.     setOptionVars(false);
  563.  
  564.     if (`optionVar -query aimConstMaintainOffset`) {
  565.         $cmd = ($cmd + " -mo");
  566.     } else {
  567.         //    Translate values
  568.         //
  569.         float $tx = `optionVar -query aimConstOffsetX`;
  570.         float $ty = `optionVar -query aimConstOffsetY`;
  571.         float $tz = `optionVar -query aimConstOffsetZ`;
  572.         $cmd = ($cmd + " -offset " + $tx + " " + $ty + " " + $tz );
  573.     }
  574.     
  575.     float $aimVector[] = `optionVar -query aimConstraintAimVector`;
  576.     float $upVector[] = `optionVar -query aimConstraintUpVector`;
  577.  
  578.     $cmd = ($cmd 
  579.             + " -weight " + `optionVar -query aimConstraintWeight`
  580.             + " -aimVector " 
  581.             + $aimVector[0] + " " + $aimVector[1] + " " + $aimVector[2]
  582.             + " -upVector " 
  583.             + $upVector[0] + " " + $upVector[1] + " " + $upVector[2]
  584.         );
  585.  
  586.     // world up related options
  587.     
  588.     string $worldUpType = `optionVar -query aimConstraintWorldUpType`;
  589.     $cmd = ($cmd  + " -worldUpType " + "\"" + $worldUpType + "\"" );
  590.     switch ( $worldUpType )
  591.     {
  592.     case "scene":
  593.     case "none":
  594.         break;
  595.     case "object":
  596.         string $worldUpObject = `optionVar -query aimConstraintWorldUpObject`;
  597.         $cmd = ($cmd  + " -worldUpObject " + $worldUpObject);
  598.         break;
  599.     case "objectrotation":
  600.         float $worldUpVector[] = `optionVar -query aimConstraintWorldUpVector`;
  601.         $cmd = ($cmd  + " -worldUpVector " 
  602.                 + $worldUpVector[0] + " "
  603.                 + $worldUpVector[1] + " "
  604.                 + $worldUpVector[2]);
  605.         string $worldUpObject = `optionVar -query aimConstraintWorldUpObject`;
  606.         $cmd = ($cmd  + " -worldUpObject " + $worldUpObject);
  607.         break;
  608.     case "vector":
  609.         float $worldUpVector[] = `optionVar -query aimConstraintWorldUpVector`;
  610.         $cmd = ($cmd  + " -worldUpVector " 
  611.                 + $worldUpVector[0] + " "
  612.                 + $worldUpVector[1] + " "
  613.                 + $worldUpVector[2]);
  614.         break;
  615.     }
  616.  
  617.     // Axis values
  618.     //
  619.  
  620.     // The axis values are inverted so that they represent
  621.     // which axes to *skip* as opposed to which axes are on.
  622.     int $axisX = !`optionVar -query aimConstraintAxisX`;
  623.     int $axisY = !`optionVar -query aimConstraintAxisY`;
  624.     int $axisZ = !`optionVar -query aimConstraintAxisZ`;
  625.  
  626.     // If any of these values is true, that means that one
  627.     // or more axes are to be skipped.
  628.     if ($axisX)
  629.         $cmd = ($cmd + " -skip x");
  630.     if ($axisY)
  631.         $cmd = ($cmd + " -skip y");
  632.     if ($axisZ)
  633.         $cmd = ($cmd + " -skip z");
  634.  
  635.     return $cmd;
  636. }
  637.  
  638. //
  639. //  Procedure Name:
  640. //      performAimConstraint
  641. //
  642. //  Description:
  643. //        Perform the aimConstraint command using the corresponding 
  644. //        option values.  This procedure will also show the option box
  645. //        window if necessary as well as construct the command string
  646. //        that will invoke the aimConstraint command with the current
  647. //        option box values.
  648. //
  649. //  Input Arguments:
  650. //      0 - Execute the command.
  651. //      1 - Show the option box dialog.
  652. //      2 - Return the command.
  653. //
  654. //  Return Value:
  655. //      None.
  656. //
  657. global proc string performAimConstraint(int $action)
  658. {
  659.     string $cmd = "";
  660.  
  661.     switch ($action) {
  662.  
  663.         //    Execute the command.
  664.         //
  665.         case 0:
  666.             //    Retrieve the option settings
  667.             //
  668.             setOptionVars(false);
  669.  
  670.             //    Get the command.
  671.             //
  672.             $cmd = `assembleCmd`;
  673.  
  674.             //    Execute the command with the option settings.
  675.             //
  676.             evalEcho($cmd);
  677.  
  678.             break;
  679.  
  680.         //    Show the option box.
  681.         //
  682.         case 1:
  683.             aimConstraintOptions;
  684.             break;
  685.  
  686.         //    Return the command string.
  687.         //
  688.         case 2:
  689.             //    Retrieve the option settings.
  690.             //
  691.             setOptionVars (false);
  692.  
  693.             //    Get the command.
  694.             //
  695.             $cmd = `assembleCmd`;
  696.             break;
  697.     }
  698.     return $cmd;
  699. }
  700.  
  701.